package com.netctoss.interceptor;

import com.netctoss.util.HibernateUtil;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class OpenSessionInViewInterceptor extends AbstractInterceptor {
	private static final long serialVersionUID = 1L;

	public String intercept(ActionInvocation in) throws Exception {
		try {
			// 前期处理——无
			in.invoke();// 调用后续的Action，Result
			HibernateUtil.closeSession();
			return null;
		} catch (Exception ex) {
			ex.printStackTrace();
			throw ex;
		} finally {
			HibernateUtil.closeSession();
			System.out.println("---CLOSE SESSION---");
		}
	}

}
